package com.tx.mq.producer;

import com.rabbitmq.client.*;

import java.io.IOException;
import java.util.concurrent.TimeoutException;


public class DlProducerTest {

    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory cf = new ConnectionFactory();
        cf.setHost("localhost");

        Connection connection = cf.newConnection();
        Channel channel = connection.createChannel();

        String message = "dl message test";
        String testDlExchange = "test-dl-exchange";
        String dlRouterKey = "dl.test";

        // channel.exchangeDeclare("dl-exchange", BuiltinExchangeType.TOPIC, true);
        AMQP.BasicProperties properties = new AMQP.BasicProperties()
                .builder()
                .deliveryMode(MessageProperties.PERSISTENT_TEXT_PLAIN.getDeliveryMode())
                .expiration("7000").build();

        for(int i=0; i<10;i++) {
            channel.basicPublish(testDlExchange, dlRouterKey, true, properties, message.getBytes());
        }
    }
}
